package nl.rug.snitter.message;

import java.util.Calendar;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Index;
import javax.jdo.annotations.Indices;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Indices({@Index(name="index_ids", members={"id"}), @Index(name="index_userId", members={"userId"})})
public class Message {

	
	@PrimaryKey
	@Persistent(valueStrategy= IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent 
	private Long userId;
	@Persistent
	private String text;
	@Persistent
	private String title;
	@Persistent
	private int hour;
	@Persistent
	private int minute;
	@Persistent
	private int day;
	@Persistent
	private int month;
	@Persistent
	private int year;

	public Message(Long userId)
	{
		this.setUserId(userId);
		this.setText("");
		this.setTitle("");
		Calendar cal= Calendar.getInstance();
		this.setHour(cal.get(Calendar.HOUR_OF_DAY));
		this.setMinute(cal.get(Calendar.MINUTE));
		this.setDay(cal.get(Calendar.DAY_OF_MONTH));
		this.setMonth(cal.get(Calendar.MONTH));
		this.setYear(cal.get(Calendar.YEAR));
	}

	public Message(Long userId, String text, String title)
	{
		this.setUserId(userId);
		this.setText(text);
		this.setTitle(title);
		Calendar cal= Calendar.getInstance();
		this.setHour(cal.get(Calendar.HOUR_OF_DAY));
		this.setMinute(cal.get(Calendar.MINUTE));
		this.setDay(cal.get(Calendar.DAY_OF_MONTH));
		this.setMonth(cal.get(Calendar.MONTH));
		this.setYear(cal.get(Calendar.YEAR));
	}

	public void setText(String text)
	{
		this.text = text;
	}

	public String getText() 
	{
		return text;
	}

	public void setTitle(String title) 
	{
		this.title = title;
	}

	public String getTitle() 
	{
		return title;
	}

	public void setHour(int hour) 
	{
		this.hour = hour;
	}

	public int getHour()
	{
		return hour;
	}

	public void setMinute(int minute)
	{
		this.minute = minute;
	}

	public int getMinute() 
	{
		return minute;
	}

	public void setDay(int day) 
	{
		this.day = day;
	}

	public int getDay() 
	{
		return day;
	}

	public void setMonth(int month)
	{
		this.month = month;
	}

	public int getMonth()
	{
		return month;
	}

	public void setYear(int year)
	{
		this.year = year;
	}

	public int getYear()
	{
		return year;
	}

	public void setUserId(Long userId)
	{
		this.userId = userId;
	}

	public Long getUserId()
	{
		return userId;
	}

	public Long getId()
	{
		return id;
	}
}
